<!DOCTYPE html>
<html>
<head>
	
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0" />
<title>蹭一族</title>
	<!-- Bootstrap 3.3.5 -->
  <link rel="stylesheet" href="/static/bootstrap/css/bootstrap.min.css"  />
  <!-- Font Awesome -->
  <link rel="stylesheet" href="/static/awesome/css/font-awesome.min.css" /> 
  <!-- Ionicons -->
  <link rel="stylesheet" href="/static/ionicon/css/ionicons.min.css" />
  <!-- DataTables -->
  <link rel="stylesheet" href="/static/plugins/datatables/dataTables.bootstrap.css">
   <!-- DataTables -->
  <link rel="stylesheet" href="https://cdn.datatables.net/1.10.11/css/jquery.dataTables.min.css">
  <!-- Theme style -->
  <link rel="stylesheet" href="/static/dist/css/AdminLTE.min.css" />
  <!-- AdminLTE Skins. Choose a skin from the css/skins
       folder instead of downloading all of them to reduce the load. -->
  <link rel="stylesheet" href="/static/dist/css/skins/_all-skins.min.css" />
  
  <link rel="stylesheet" href="/static/js/img/img.css" type="text/css">
    
    
<link href="/static/bootstrapValidate/css/bootstrapValidator.min.css" rel="stylesheet" />
 <style>
 	tbody tr td{ text-align:center; }
 </style>

<!-- ./wrapper -->	

</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
	<#-- header -->
  <#include  "/admin/layouts/header.ftl" >
  
  <div class="content-wrapper">
  
  <section class="content-header">
      <h1>
        <span></span>
        <small>活动商品审核</small>
      </h1>
      <ol class="breadcrumb">
        <li><a href="/manager/${sys}"><i class="fa fa-dashboard"></i>主页</a></li>
        <li class="active"   >活动商品审核</li>
      </ol>
    </section>
 	 <#-- 左侧导航栏-->
  	<#if Session.session_admin_user['ROLE_CODE']=='ADMIN'>
 	 	<#include  "/admin/menu/sidebar_admin.ftl" />
	</#if>
	<#-- 左侧导航栏-->
  	<#if Session.session_admin_user['ROLE_CODE']=='ADMINISTRATOR'>
 	 	<#include  "/admin/menu/sidebar_administrator.ftl" />
	</#if>
    <#-- 内容 -->
    <section class="content"  >
       <table>
       		<tr>
       			<td>
       				<a class="btn btn-app" onclick="delFun()"  >
	                	<i class="fa fa-minus"></i> 删除
	              	</a>
       			</td>
       		</tr>
       </table>
    
       <table id="datatable" class="table table-bordered table-striped">
                <thead>
	                <tr >
	                  <th>活动标题</th>
	                  <th>商家名称</th>
	                  <th>图片</th>
	                  <th>组图</th>
	                  <th>商家地址</th>
	                  <th>联系方式</th>
	                  <th>排序</th>
	                  <th>排序操作</th>
	                  <th>店铺状态</th>
	                  <th>状态</th>
	                  <th>操作</th>
	                  <th>创建时间</th>
	                </tr>
                </thead>
        </table>
      
    </section>
  </div>
  
  
  <#-- /.content-wrapper -->
  <#include "/admin/layouts/footer.ftl" />

  <#-- Control Sidebar -->
  <#include  "/admin/layouts/controlSidebar.ftl" />
</div>

<!-- jQuery 2.1.4 -->
<script src="/static/plugins/jQuery/jQuery-2.1.4.min.js"></script>
<!-- jQuery UI 1.11.4 -->
<script src="/static/js/jqueryUi.min.1.11.4.js"></script>
<!-- Resolve conflict in jQuery UI tooltip with Bootstrap tooltip -->
<!-- Bootstrap 3.3.5 -->
<script src="/static/bootstrap/js/bootstrap.min.js"></script>
<!-- Morris.js charts 
<script src="/static/plugins/morris/morris.min.js"></script>
-->

<!-- DataTables -->
<script src="/static/plugins/datatables/jquery.dataTables.min.js"></script>
<script src="/static/plugins/datatables/dataTables.bootstrap.min.js"></script>
<!-- Slimscroll -->
<script src="/static/plugins/slimScroll/jquery.slimscroll.min.js"></script>
<!-- FastClick -->
<script src="/static/plugins/fastclick/fastclick.js"></script>
<!-- AdminLTE App -->
<script src="/static/dist/js/app.min.js"></script>

<#-- AdminLTE for demo purposes -->
<script src="/static/dist/js/demo.js"></script>
<!-- layer-->
<script src="/static/layer/layer.js"></script>

<!-- layer-->
<script src="/static/js/syUI.js"></script>


<script type="text/javascript" src="/static/js/uploadify/swfobject.js"></script>
<script type="text/javascript" src="/static/js/uploadify/jquery.uploadify.js"></script>
<!-- 引入ui扩展 -->
<script src="/static/js/core.ui.js" type="text/javascript" charset="utf-8"></script>
<!-- 引入图片裁剪-->
<link rel="stylesheet" href="/static/js/tapmodo-Jcrop-1902fbc/css/jquery.Jcrop.css" type="text/css">
<script type="text/javascript" src="/static/js/tapmodo-Jcrop-1902fbc/js/jquery.Jcrop.js"></script>
<script type="text/javascript" src="/static/js/tapmodo-Jcrop-1902fbc/js/jquery.Jcrop.min.js"></script>
<!-- 浏览大图 -->
<script type="text/javascript" src="/static/js/img/img.js"></script>

<script type="text/javascript" src="/static/js/ut.js" ></script>

<script src="/static/bootstrapValidate/js/bootstrapValidator.min.js"></script>

<script>
	var table ;
	$(function(){
		table = $("#datatable").dataTable({
	      "processing": true,
	      "serverSide": true,
	       ordering:false,
	      "ajax" : "/indexActStore/list",
	       "oLanguage" : {
                "sLengthMenu": "每页显示 _MENU_ 条记录",
                "sZeroRecords": "抱歉， 没有找到",
                "sInfo": "从 _START_ 到 _END_ /共 _TOTAL_ 条数据",
                "sInfoEmpty": "没有数据",
                "sInfoFiltered": "(从 _MAX_ 条数据中检索)",
                "sZeroRecords": "没有检索到数据",
                "sSearch": "商品名称:",
                "oPaginate": {
                "sFirst": "首页",
                "sPrevious": "前一页",
                "sNext": "后一页",
                "sLast": "尾页"
                }
                     
            },
            "aoColumnDefs": [
			{
			 sDefaultContent: '',
			 aTargets: [ '_all' ]
			  }
			],
	      <!-- "fnServerData":retrieveData, //与后台交互获取数据的处理函数 
	         -->
	      "columns": [
	       <!-- {"data": "id",sWidth:'3%'},, "bSortable": false -->
	        {"data": "title",sWidth:'10%'},
	        {"data": "storeName",sWidth:'8%'},
	        {
	        	"data": "logo",sWidth:'3%',
	        	"render": function(data, type, full) {
	        		if(data.indexOf('http')==-1){
	        			return po.showImg(data,20,20);
	        		}
		            return "<img src='" + data + "' width='20px' height='20px' ></img>";
		          }
	        },
	        {
	        	"data": "imgs",sWidth:'5%',
	        	"render": function(data, type, full) {
	        		if(!data) return "";
	        		if(data.indexOf('http')==-1){
	        			return po.showImg(data,20,20);
	        		}
	        		var imgs = data.split(',');
	        		var str = "";
	        		for(var i = 0 ; i < imgs.length ; i++) {
	        			str+="<img src='" + imgs[i] + "' width='20px' height='20px' ></img>";
	        		}
		            return str;
		          }
	        },
	        {
	        	"data": "address",sWidth:'10%'
	        },
	        {"data": "phone",sWidth:'10%'},
	        {
	        	"data": "sortOrder",sWidth:'6%'
	        },{
	        	"data": "sortOper",sWidth:'3%',
	        	"render": function(data, type, full) {
	        		return "<button  onclick='changesort(\""+full.id+"\")' type='button' class='btn btn-block btn-primary'>修改排序</button>";
		          }
	        },
	        
	        {
	        	"data": "closed",sWidth:'8%',
	        	"render": function(data, type, full) {
	        		if(data==1){
	        			return "<span style='color:green;' >在线</span> ";
	        		}else if(data==0){
	        			return "<span style='color:red;' >关店中</span> ";
	        		}
		          }
	        },{
	        	"data": "state",sWidth:'8%',
	        	"render": function(data, type, full) {
	        		if(data==1){
	        			return "<span style='color:red;' >未审核</span> ";
	        		}else if(data==2){
	        			return "<span style='color:green;' >审核未通过</span> ";
	        		}else{
	        			return "审核通过 ";
	        		}
		          }
	        },
	        {
	        	"data": "oper",sWidth:'8%',
	        	"render": function(data, type, full) {
	        		if(full.state==1)  return "[<a href='javascript:void(0);' onclick='online(\""+full.id+"\",3)'  >通过</a>]  [<a href='javascript:void(0);' onclick='online(\""+full.id+"\",2)' >不通过</a>]";
	        		if(full.state==2)  return "[无]";
	        		if(full.state==3)  return "[无]";
		         }
	        },
	        {"data": "createTime",sWidth:'8%'},
	      ]
	    });
	    
	    $("#datatable tbody").click(function (event) {
            $(table.fnSettings().aoData).each(function () {
                $(this.nTr).removeClass('selected');
            });
            $(event.target.parentNode).addClass('selected');
            
        });

        $('#datatable tbody tr').click(function (event) {
            var aData = table.fnGetData(this); // get datarow
            if (null != aData)  // null if we clicked on title row
            {
                var tt = aData[0];
                alert(tt);
               document.getElementById("Hidden1").value = tt;
            }
        });
	});
	
	var delFun = function(){
			var rows = sy.fnGetSelected(table);
			if (rows.length == 0) {
				parent.$.messager.w('请选择需要删除的记录！');
				return;
			}
			parent.$.messager.confirm('询问', '您确定要删除此活动商家吗？', function(r) {
				if (r) {
					var ids = [];
					for ( var i = 0, l = rows.length; i < l; i++) {
						var r = rows[i];
						ids.push(r.id);
					}
					var id = ids.join(',');
					
					$.post(sy.contextPath + '/indexActStore/del', {
						id : id
					}, function() {
						table.fnDraw(false);
					}, 'json');
				}
			});
		}
	var online = function (id,type){
		if (type == 3){
			parent.$.messager.prompt(false,'请输入排序[0-9999]',function(r){
				if (r){
					if(!UT.isInt(r)||r>9999||r<0){
						parent.$.messager.e("只能输入0-9999间数字");
						return;
					}
					var data = {
							id : id,
							state : 3,
							sortOrder:r
							
					};
					SaveData(data);
				}
			});
		}else {
			parent.$.messager.prompt(false,'请输入驳回原因(少于50字)',function(r){
				if (r){
					if(r.length>50){
						parent.$.messager.e("字数超过限制");
						return;
					}
					var data = {
							id : id,
							state : 2,
							remark:r
					};
					SaveData(data);
				}
			});
		}
	}
	
	var changesort = function (id){
		parent.$.messager.prompt(false,'请输入排序数值[0-9999]',function(r){
				if (r){
					if(!UT.isInt(r)||r>9999||r<0){
						parent.$.messager.e('只能输入0-9999间数字');
						return;
					}
					var data = {
							id : id,
							sortOrder : r
					};
					SaveData(data);
				}
		});
	}
	
	
	function SaveData(data) {
		$.post(sy.contextPath + '/indexActStore/update', data, function() {
			table.fnDraw(false);
		}, 'json');
	}
</script>

</body>
</html>
